package com.aaa.day1104.demo02;

import java.util.function.Supplier;

/**
 * @author ${崔灿}
 * @date 2022/11/04 17:06
 **/

public class Test03 {
    public static void main(String[] args) {
        //无参，返回学生对象名称
        Student s = new Student("张三", "45");

        //观察lambda表达式，对象名.实例方法
        //Supplier<String> supplier=()->s.getName();

        //方法引用
        Supplier<String> supplier=s::getName;

        System.out.println(supplier.get());
    }
}
class Student{
    private String name;
    private String age;

    public Student(String name, String age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age='" + age + '\'' +
                '}';
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
}
